package com.ruoyi.study.strategy;

import com.ruoyi.study.api.domain.StudySummaryDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Map;

@Component
public class PushContext {
    @Autowired
    private Map<String, PushStrategy> pushStrategies; // Spring自动注入所有PushStrategy实现

    /** 执行指定策略的推送 */
    public void push(String strategyType, StudySummaryDTO dto) {
        PushStrategy strategy = pushStrategies.get(strategyType);
        if (strategy == null) {
            throw new IllegalArgumentException("未找到推送策略：" + strategyType);
        }
        strategy.push(dto);
    }
}